# from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
# from sqlalchemy.orm import relationship, backref
# from base import Base
# from role_permission import role_permissions
# from admin_menu_permission import admin_menu_permission
#
# class Permission(Base):
#     __tablename__ = 'permissions'
#
#     id = Column(Integer, primary_key=True, index=True)
#     name = Column(String(255), nullable=False, comment='权限名称')
#     description = Column(String(255), nullable=True, comment='权限描述')
#     parent_id = Column(Integer, ForeignKey('permissions.id'), nullable=True, comment='父权限ID')
#     created_at = Column(DateTime(timezone=True), nullable=False, comment='创建时间')
#     updated_at = Column(DateTime(timezone=True), nullable=False, comment='更新时间')
#     deleted_at = Column(DateTime(timezone=True), nullable=True, comment='删除时间')
#     children = relationship("Permission", backref=backref('parent', remote_side=[id]))
#     roles = relationship('Role', secondary=role_permissions, back_populates='permissions')
#     menus = relationship("AdminMenu", secondary=admin_menu_permission, back_populates="permissions")
#
#     def to_dict(self):
#         return {c.name: getattr(self, c.name) for c in self.__table__.columns}
